package com.qzsf.backend.service;

/*
 * @Author: Dennis Chen
 * @CreateTime: 2024/10/11 10:31 周五
 * @Email 1429278462@qq.com
 * @Remark 邮箱发送服务类
 * @Version 1.0
 */
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;

@Service
public class EmailService {

    @Autowired
    private JavaMailSender mailSender;

    public void sendVerificationCode(String toEmail, String verificationCode) {
        SimpleMailMessage message = new SimpleMailMessage();
        message.setTo(toEmail);
        message.setSubject("Verification Code");
        message.setText("【验证码】当前你的验证码是：" + verificationCode+" 如非本人操作，请忽略本邮件。五分钟之内有效");
        message.setFrom("1429278462@qq.com");

        mailSender.send(message);
    }
}
